package com.yan.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义业务异常类封装
 * @author yanchen
 */
@EqualsAndHashCode(callSuper = true)
@Data
public final class ServiceException extends RuntimeException{

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public ServiceException() {
    }

    public ServiceException(String message){
        this.message = message;
    }

    public ServiceException( Integer code,String message) {
        this.message = message;
        this.code = code;
    }

    public ServiceException( Integer code,String message, String detailMessage) {
        this.message = message;
        this.code = code;
        this.detailMessage = detailMessage;
    }

}